<!DOCTYPE html>
<html lang="zh">
<head>
    <meta charset="UTF-8">
    <title>按键监听</title>
    <script type="text/javascript">
        function method01(){
            //onkeydown监听全键
            alert('onkeydown方法执行！');
        }
        //其他监听部分键
        function method02(){
            alert('onkeypress方法执行！');
        }
        function method03(){
            alert('onkeyup方法执行！');
        }
        function method04(){
            alert('up');
        }
        function method05(){
            alert('onkeydown');
        }
    </script>
</head>
<body>
<input type="text" onkeydown="method01()"><br>
<input type="text" onkeypress="method02()"><br>
<hr>
<input type="text" onkeyup="method03()"><br>
<hr>
<input type="text" onkeyup="method04()" onkeydown="method05()"><br>
</body>
</html>